<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>dataMethod</title>
    <script src="https://unpkg.com/vue@3"></script>
</head>

<body>
    <div id="app">
        <div>{{count}}</div>
        <button @click="add">Add</button>
    </div>
</body>
<script>
    const App = Vue.createApp({
        data() {
            return {
                count: 0
            }
        },
        // computed 选项定义计算属性 
        computed: {
            type: {
                // 计算属性的 get 方法
                get() {
                    return this.count > 10 ? 'big' : 'small'
                },
                // 计算属性的 set 方法
                set(value) {
                    if (value == "big") {
                        this.count = 11
                    } else {
                        this.count = 0
                    }
                }
            }
        },
        methods: {
            add() {
                this.count++
            }
        }
    }).mount('#app')
</script>

</html>